<%@ page contentType="text/html; charset=utf-8" pageEncoding="utf-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="f" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="s" uri="http://stripes.sourceforge.net/stripes.tld" %>

<s:layout-render name="/menu.jsp" nadpis="Course">
    <s:layout-component name="telo">
        <s:useActionBean beanclass="com.pa165.languageschoolpresentation.CourseActionBean" var="actionBean"/>
        <f:message key="Total"/> = ${actionBean.courses.size()}:
        <table class="table">
            <tr>
                <th><f:message key="Number"/></th>
                <th><f:message key="Id"/></th>
                <th><f:message key="Name"/></th>               
                <th><f:message key="CourseDifficulty"/></th>       
                <th><f:message key="CourseLanguage"/></th> 
                <c:if test="${pageContext.request.isUserInRole('ROLE_ADMIN')}" >
                    <th></th>
                    <th></th>
                </c:if>
                <th></th>

            </tr>
            <c:forEach items="${actionBean.courses}" var="courseDTO" varStatus="loop">
                <tr>
                    <td>${loop.index}</td>
                    <td>${courseDTO.id}</td>                   
                    <td><c:out value="${courseDTO.name}"/></td> 
                    <td><f:message key="com.pa165.languageschoolpersistence.entities.Difficulty.${courseDTO.difficulty}"/></td> 
                    <td><f:message key="com.pa165.languageschoolpersistence.entities.LanguageSpoken.${courseDTO.language}"/></td>
                    <c:if test="${pageContext.request.isUserInRole('ROLE_ADMIN')}" >
                        <td><s:link beanclass="com.pa165.languageschoolpresentation.CourseActionBean" event="delete"><s:param name="courseDTO.id" value="${courseDTO.id}"/><f:message key="Delete"/></s:link> </td>
                        <td><s:link beanclass="com.pa165.languageschoolpresentation.CourseActionBean" event="edit"><s:param name="courseDTO.id" value="${courseDTO.id}"/><f:message key="Edit"/></s:link> </td>
                    </c:if>  
                    <td><s:link beanclass="com.pa165.languageschoolpresentation.CourseActionBean" event="showLectures"><s:param name="courseDTO.id" value="${courseDTO.id}"/><f:message key="ShowLectures"/></s:link> </td>

                </tr>
            </c:forEach>
        </table>
        <c:if test="${pageContext.request.isUserInRole('ROLE_ADMIN')}" >       
            <s:link beanclass="com.pa165.languageschoolpresentation.CourseActionBean" event="add"><f:message key="Add"/></s:link> 
        </c:if>
    </s:layout-component>
</s:layout-render>
